package com.fr.data.condition;

import com.fr.base.XMLable;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.core.DataXMLUtils;

public class JoinCondition
  implements XMLable
{
  private int join = 0;
  private Condition condition;

  public JoinCondition()
  {
  }

  public JoinCondition(int paramInt, Condition paramCondition)
  {
    this.join = paramInt;
    this.condition = paramCondition;
  }

  public int getJoin()
  {
    return this.join;
  }

  public void setJoin(int paramInt)
  {
    this.join = paramInt;
  }

  public Condition getCondition()
  {
    return this.condition;
  }

  public void setCondition(Condition paramCondition)
  {
    this.condition = paramCondition;
  }

  public boolean equals(Object paramObject)
  {
    if ((paramObject == null) || (!(paramObject instanceof JoinCondition)))
      return false;
    JoinCondition localJoinCondition = (JoinCondition)paramObject;
    return ((localJoinCondition.getJoin() == getJoin()) && (ComparatorUtils.equals(localJoinCondition.getCondition(), getCondition())));
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isAttr())
    {
      String str;
      if ((str = paramXMLableReader.getAttr("join")) != null)
        this.join = Integer.parseInt(str);
    }
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().endsWith("Condition")))
      this.condition = DataXMLUtils.readXMLCondition(paramXMLableReader);
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("JoinCondition").attr("join", getJoin());
    DataXMLUtils.writeXMLCondition(paramXMLPrintWriter, this.condition);
    paramXMLPrintWriter.end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    JoinCondition localJoinCondition = (JoinCondition)super.clone();
    localJoinCondition.join = this.join;
    if (this.condition != null)
      localJoinCondition.condition = ((Condition)this.condition.clone());
    return localJoinCondition;
  }

  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer();
    if (getJoin() == 0)
      localStringBuffer.append("and ");
    else
      localStringBuffer.append("or  ");
    localStringBuffer.append(getCondition());
    return localStringBuffer.toString();
  }
}